package from;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class List2Page extends WebPage {
    private static List SITES = new ArrayList();
    private static Map NAMES = new HashMap();

    static {
        SITES.add("http://aa.com");
        SITES.add("http://bb.com");
        SITES.add("http://cc.com");

        NAMES.put("http://aa.com", "aa");
        NAMES.put("http://bb.com", "bb");
        NAMES.put("http://cc.com", "cc");
    }

    public List2Page(){
        super();

        ListView listView = new ListView("listView",SITES) {
            @Override
            protected void populateItem(ListItem item) {
                String name =(String) NAMES.get(item.getModelObject());
                item.add(new Label("name",name));
                item.add(new ExternalLink("url",(String) item.getModelObject()));
            }
        };
        this.add(listView);
    }
}
